package com.openbravo.data.gui;

import com.openbravo.data.loader.LocalRes;
import java.awt.Component;
import javax.swing.Icon;
import javax.swing.UIManager;

public class MessageInf
{
  public static final int SGN_DANGER = -16777216;
  public static final int SGN_WARNING = -33554432;
  public static final int SGN_CAUTION = -50331648;
  public static final int SGN_NOTICE = -67108864;
  public static final int SGN_IMPORTANT = -100663296;
  public static final int SGN_SUCCESS = -83886080;
  public static final int CLS_GENERIC = 0;
  private int m_iMsgNumber;
  private String m_sHazard;
  private String m_sConsequences;
  private String m_sAvoiding;
  private Object m_eCause;

  public MessageInf(int paramInt, String paramString, Object paramObject)
  {
    this.m_iMsgNumber = (paramInt | 0x0);
    this.m_sHazard = paramString;
    this.m_sConsequences = "";
    this.m_sAvoiding = "";
    this.m_eCause = paramObject;
  }

  public MessageInf(int paramInt, String paramString)
  {
    this(paramInt, paramString, null);
  }

  public MessageInf(Throwable paramThrowable)
  {
    this(-33554432, paramThrowable.getLocalizedMessage(), paramThrowable);
  }

  public void show(Component paramComponent)
  {
    JMessageDialog.showMessage(paramComponent, this);
  }

  public Object getCause()
  {
    return this.m_eCause;
  }

  public int getSignalWord()
  {
    return this.m_iMsgNumber & 0xFF000000;
  }

  public Icon getSignalWordIcon()
  {
    int i = getSignalWord();
    if (i == -16777216)
      return UIManager.getIcon("OptionPane.errorIcon");
    if (i == -33554432)
      return UIManager.getIcon("OptionPane.warningIcon");
    if (i == -50331648)
      return UIManager.getIcon("OptionPane.warningIcon");
    if (i == -67108864)
      return UIManager.getIcon("OptionPane.informationIcon");
    if (i == -100663296)
      return UIManager.getIcon("OptionPane.informationIcon");
    if (i == -83886080)
      return UIManager.getIcon("OptionPane.informationIcon");
    return UIManager.getIcon("OptionPane.questionIcon");
  }

  public String getErrorCodeMsg()
  {
    StringBuffer localStringBuffer = new StringBuffer();
    int i = getSignalWord();
    if (i == -16777216)
      localStringBuffer.append("DNG_");
    else if (i == -33554432)
      localStringBuffer.append("WRN_");
    else if (i == -50331648)
      localStringBuffer.append("CAU_");
    else if (i == -67108864)
      localStringBuffer.append("NOT_");
    else if (i == -100663296)
      localStringBuffer.append("IMP_");
    else if (i == -83886080)
      localStringBuffer.append("INF_");
    else
      localStringBuffer.append("UNK_");
    localStringBuffer.append(toHex((this.m_iMsgNumber & 0xFF0000) >> 16, 2));
    localStringBuffer.append('_');
    localStringBuffer.append(toHex(this.m_iMsgNumber & 0xFFFF, 4));
    return localStringBuffer.toString();
  }

  private String toHex(int paramInt1, int paramInt2)
  {
    String str = Integer.toHexString(paramInt1);
    return fillString(paramInt2 - str.length()) + str;
  }

  private String fillString(int paramInt)
  {
    char[] arrayOfChar = new char[paramInt];
    for (int i = 0; i < arrayOfChar.length; i++)
      arrayOfChar[i] = '0';
    return new String(arrayOfChar);
  }

  public String getMessageMsg()
  {
    StringBuffer localStringBuffer = new StringBuffer();
    int i = getSignalWord();
    if (i == -16777216)
      localStringBuffer.append(LocalRes.getIntString("sgn.danger"));
    else if (i == -33554432)
      localStringBuffer.append(LocalRes.getIntString("sgn.warning"));
    else if (i == -50331648)
      localStringBuffer.append(LocalRes.getIntString("sgn.caution"));
    else if (i == -67108864)
      localStringBuffer.append(LocalRes.getIntString("sgn.notice"));
    else if (i == -100663296)
      localStringBuffer.append(LocalRes.getIntString("sgn.important"));
    else if (i == -83886080)
      localStringBuffer.append(LocalRes.getIntString("sgn.success"));
    else
      localStringBuffer.append(LocalRes.getIntString("sgn.unknown"));
    localStringBuffer.append(this.m_sHazard);
    localStringBuffer.append(this.m_sConsequences);
    localStringBuffer.append(this.m_sAvoiding);
    return localStringBuffer.toString();
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.data.gui.MessageInf
 * JD-Core Version:    0.6.0
 */